<template>
  <div>
    <Wrap>
      <!-- <div slot="main_wrap">
        <avue-crud ref="crud"
            :page.sync="page"
            :data="tableData"
            :permission="permissionList"
            :table-loading="tableLoading"
            :option="tableOption"
            @on-load="getList"
            @search-change="searchChange"
            @refresh-change="refreshChange"
            @size-change="sizeChange"
            @current-change="currentChange">
            <template slot="menuLeft">
              <el-button type="primary" @click="goUrl">预警记录</el-button>
            </template>
        </avue-crud>
      </div> -->
    </Wrap>
  </div>
</template>

<script type="text/ecmascript-6">
import Wrap from '@/components/energy-wrap'
import {tableOption} from '@/const/crud/energy/total'
import { meterRead } from '@/api/energy/energy'
export default {
  components: {
    Wrap
  },
  data () {
    return {
      form1: {},
      searchForm: {},
      tableData: [],
      modal1: false,
      page: {
          total: 0, // 总页数
          currentPage: 1, // 当前页数
          pageSize: 20 // 每页显示多少条
      },
      tableLoading: false,
      tableOption: tableOption
    }
  },
  computed: {
      permissionList() {
          return {
              addBtn: false,
              delBtn: false,
              editBtn: false
          };
      }
  },
  created() {
      // this.init()
  },
  methods: {
      goUrl() {
        this.$router.push({
          path: '/energy/alarm/record'
        })
      },
      getList(page, params) {
          this.tableLoading = true
          if (this.searchForm.dateRange) {
                this.searchForm.startDate = this.searchForm.dateRange[0];
                this.searchForm.endDate = this.searchForm.dateRange[1];
            }
          meterRead(Object.assign({
              current: page.currentPage,
              size: page.pageSize
          }, params, this.searchForm )).then(response => {
              this.tableData = response.data.data.records
              this.page.total = response.data.data.total
              this.tableLoading = false
          }).catch(() => {
              this.tableLoading=false
          })
      },
      sizeChange(pageSize){
          this.page.pageSize = pageSize
      },
      currentChange(current){
          this.page.currentPage = current
      },
      searchChange(form, done) {
          this.searchForm = form
          this.page.currentPage = 1
          this.getList(this.page, form)
          done()
      },
      refreshChange() {
          this.getList(this.page)
      }
  }
}
</script>

<style lang="scss" scoped>
</style>
